package com.wicket.okrbff.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrbff.biz.service.AppSceneService;
import com.wicket.okrbff.biz.service.dto.common.BffBizAppSceneDto;
import com.wicket.okrbff.biz.service.dto.common.BffBizAppSceneRelDto;
import com.wicket.okrbff.biz.service.dto.common.BffBizSceneDto;
import com.wicket.okrbff.biz.service.dto.req.QueryHostTypeCollectionRemoveExistingDataListReqDto;
import com.wicket.okrbff.biz.service.dto.req.*;
import com.wicket.okrbff.biz.service.dto.res.QueryHostTypeCollectionRemoveExistingDataListRespDto;
import com.wicket.okrbff.biz.service.dto.res.*;
import com.wicket.okrbff.biz.service.nb.NbAppScene;
import com.wicket.okrbff.common.util.RedisUtil;
import com.wicket.okrframework.integration.FwBaseAppSceneClient;
import com.wicket.okrframework.integration.FwBaseDivineDataClient;
import com.wicket.okrframework.integration.FwBaseHostTypeClient;
import com.wicket.okrframework.integration.FwBaseInductionRecordClient;
import com.wicket.okrframework.integration.dto.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;
import com.wicket.okrbff.common.exception.Assert;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class AppSceneServiceImpl implements AppSceneService {

    @Resource
    FwBaseAppSceneClient appSceneClient;
    @Resource
    FwBaseAppSceneClient fwBaseAppSceneClient;
    @Resource
    FwBaseHostTypeClient fwBaseHostTypeClient;
    @Resource
    FwBaseDivineDataClient fwBaseDivineDataClient;
    @Resource
    NbAppScene nbAppScene;
    @Resource
    FwBaseInductionRecordClient fwBaseInductionRecordClient;
    @Resource
    private RedisUtil redisUtil;


    /**
   * B1-1查询业务场景列表（边界）	[770]
   * gen by moon at 8/10/2022, 3:30:23 AM
   */
    @Trace(operationName = "B1-1查询业务场景列表（边界）	")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryBizSceneMenuListRespDto queryBizSceneMenuList(BffQueryBizSceneMenuListReqDto reqDto){
      
       
       QueryBizSceneListRespDto queryBizSceneListRespDto_1 = null;
//步骤0: D1-1查询业务场景列表 - queryBizSceneList
     QueryBizSceneListRespDto queryBizSceneListRespDto = null;
    QueryBizSceneListReqDto queryBizSceneListReqDto=new QueryBizSceneListReqDto();
  queryBizSceneListReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:33202_1
if(reqDto!=null){
      queryBizSceneListReqDto.setBizAppId(reqDto.getBizAppId());//sourceId:33200_1
    }
  
    /*D1-1查询业务场景列表[753]   */
    Assert.isNull(queryBizSceneListReqDto.getBizAppId(),"B1-1查询业务场景列表（边界）	-D1-1查询业务场景列表-业务应用ID不能为空",false);
Assert.isNull(queryBizSceneListReqDto.getSubjectLifeCycle(),"B1-1查询业务场景列表（边界）	-D1-1查询业务场景列表-主体生命周期不能为空",false);
      queryBizSceneListRespDto = fwBaseAppSceneClient.queryBizSceneList(queryBizSceneListReqDto).getData();
      
      queryBizSceneListRespDto_1 = queryBizSceneListRespDto;
    
BffQueryBizSceneMenuListRespDto retData = new BffQueryBizSceneMenuListRespDto();
  if(queryBizSceneListRespDto_1!=null){
      retData.setBizSceneList(queryBizSceneListRespDto_1.getBizSceneList().stream().map(item -> BeanUtil.toBean(item, BffBizSceneDto.class)).collect(Collectors.toList()));//sourceId:33205_1
    }
  

  
  
return retData;
  }

    /**
     * B1-1查询业务应用菜单列表（边界）[766]
     */
    @Trace(operationName = "B1-1查询业务应用菜单列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryBizAppSceneMenuListRespDto queryBizAppSceneMenuList(BffQueryBizAppSceneMenuListReqDto reqDto) {


        //步骤0: D1-1查询业务应用菜单列表（边界） - queryBizAppSceneMenuList
        QueryBizAppSceneMenuListRespDto queryBizAppSceneMenuListRespDto = null;
        QueryBizAppSceneMenuListReqDto queryBizAppSceneMenuListReqDto = new QueryBizAppSceneMenuListReqDto();


        /*D1-1查询业务应用菜单列表（边界）[1441]   */
        queryBizAppSceneMenuListRespDto = fwBaseAppSceneClient.queryBizAppSceneMenuList(queryBizAppSceneMenuListReqDto).getData();


        BffQueryBizAppSceneMenuListRespDto retData = new BffQueryBizAppSceneMenuListRespDto();
        retData.setBizAppSceneList(queryBizAppSceneMenuListRespDto.getBizAppSceneList().stream().map(item -> BeanUtil.toBean(item, BffBizAppSceneDto.class)).collect(Collectors.toList()));//sourceId:34355_1


        return retData;
    }


}
